import proxy
import common
import threading
from wx.lib.newevent import NewEvent



GLOBAL_VARS = common.getGlobalVars()

def startProxyThread(presenter):
    t = threading.Thread(name = "proxy",target = proxy.proxyStart,
                         args = (presenter,))
    t.start()

class Presenter():
    def __init__(self,write_pointer,init_pointer):
        self._writer = write_pointer
        self._init = init_pointer

    def init(self, status):
        self._init(status)
        
    def write(self,string):
        self._writer(string)

    def save(self, variable_dict):
        GLOBAL_VARS.FETCH_SERVER = variable_dict["FETCH_SERVER"]
        GLOBAL_VARS.IPV6_ENABLE = variable_dict["IPV6_ENABLE"]
        GLOBAL_VARS.PROTOCOL = variable_dict["PROTOCOL"]
        GLOBAL_VARS.writeConf()

    def shutdown(self):
        proxy.proxyShutdown()
        

